package com.tencent.crazypenguin.config;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import com.tencent.crazypenguin.bean.User;
import com.tencent.crazypenguin.dao.UserDao;

import net.sf.json.JSONObject;

public class HbmUtil {
	
	private static SessionFactory sessionfactory = new Configuration().configure().buildSessionFactory();

	public static Session getSession() {
		return sessionfactory.openSession();
	}
	
	public static void main(String[] args){
		System.out.println(new UserDao().findById(new Long(1), new User()));
	}
	
	public static JSONObject getAuthDate(){
		HttpServletRequest request = ServletActionContext.getRequest();
		JSONObject authJson = (JSONObject) request.getAttribute("authData");
		return authJson;
	}
	
	

}
